/*
java.io.InputStreamReader;
可以使用charset设定指定编码方式读取字节并且转换为字符

java.io.OutputStreamWriter;
可以使用charset设定指定编码方式读取字符并且转换为字节
 */


public class demo{

    public static void main(String[] args) throws IOException{
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("文件"),"utf-8");  //编码表大小写都可以

        osw.write("你好");

        osw.flush();

        osw.close();


        InputStreamReader isr = new InputStreamReader(new FileInputStream("文件"),"utf-8");

        int len = 0;
        while(len = isr.read() != -1){
            System.out.println((char)/*强转*/len);
        }

        isr.close();

    }

}